@extends('admin.public')

@section('content')
    <div class="col-md-12">
        <section class="panel panel-default text-sm doc-buttons">
            <div class="panel-body">
                <a href="{{ route('admin.chunk.chunk_add') }}" class="btn btn-info"><i class="icon-plus ico"></i>
                    &nbsp; 添加模块</a>
            </div>
        </section>
    </div>

    <div class="col-md-12">
        <section class="panel panel-default">
            <header class="panel-heading">
                {{ $frame['title'] }}
            </header>
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th class="col-md-2">模块名称</th>
                        <th class="col-md-2">分页数量</th>
                        <th class="col-md-2">分类标签
                            <small class="text-small">(用于遍历)</small>
                        </th>
                        <th class="col-md-2">信息标签
                            <small class="text-small">(用于遍历)</small>
                        </th>
                        <th class="col-md-2">发布权限</th>
                        <th class="col-md-2">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if( !empty($chunks) )
                        @foreach($chunks as $chunk)
                            <tr>
                                <td class="col-md-2">
                                    <a href="{{ route('show',$chunk['path']) }}" target="_blank">
                                        {{ $chunk['name'] }}
                                    </a>
                                </td>
                                <td class="col-md-2">{{ $chunk['paginate'] }} 条/页</td>
                                <td class="col-md-2">{{ '{' }}{ $sorts['{{ $chunk['path'] }}'] }}</td>
                                <td class="col-md-2">{{ '{' }}{ $allInfos['{{ $chunk['path'] }}'] }}</td>
                                <td class="col-md-2">{{ (bool)$chunk['user_write']?'全部账号':'仅管理员' }}</td>
                                <td class="col-md-2">
                                    <button class="btn btn-xs btn-info"
                                            data-toggle="popover"
                                            data-html="true"
                                            data-placement="top"
                                            data-content="<div class='scrollable' style='height:100px'>
                                            @foreach($chunk['themes'] as $key => $theme)
                                            {{ $key }}:{{ $theme }}.blade.php &nbsp;&nbsp;&nbsp;&nbsp;<br style='margin-bottom:3px'>
                                            @endforeach
                                                    </div>"
                                            title="{{ $chunk['name'] }}模版"
                                            data-original-title="">
                                        <i class="ico icon-layers"></i>
                                    </button>
                                    <a href="{{ route('admin.sort.sort_add',$chunk['id']) }}"
                                       class="btn btn-xs btn-default">添加分类</a>
                                    @if( (bool)\Auth::guard('admin')->user()->is_root )
                                        <a href="{{ route('admin.chunk.chunk_edit',$chunk['id']) }}"
                                           class="btn btn-xs btn-default">编辑</a>
                                        <a href="{{ route('admin.chunk.chunk') }}?del={{ $chunk['id'] }}"
                                           class="btn btn-xs btn-danger">删除</a>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>
            </div>
        </section>
    </div>
@endsection

@section('css')
@endsection

@section('js')
@endsection